/**
 * 功能描述 列表
 */
define(function (require, exports, module) {
	var Grid = require("grid"); 	
	var aw = require("ajaxwrapper")
	var Dialog = require("dialog");
	var store =require("store");
	var activeUser = store.get("user");	
	
	var intentionregister_Props = require("../constant/intentionregister_Props");
	var intentionRegisterGrid_Events = require("../handler/IntentionRegisterGrid_Events");

    var instance = {
        initComponent: function (params, widget) {
        	var grid = new Grid({
        		autoRender:false,
                parentNode : ".J-grid",
                url : "api/customervisitrecord/queryall",
                params : function(){
                		var obj={
                				"customer.productType":widget.get("subnav").getValue("productType"),
                				"customer.intention":widget.get("subnav").getValue("intention"),
                				"saleConsultant":activeUser.pkUser,
                				"recordType":"Visit",
                				"customer.status":widget.get("subnav").getValue("status"),
                				"customer.visitTime":widget.get("subnav").getValue("visitTime").start,
                				"customer.visitTimeEnd":widget.get("subnav").getValue("visitTime").end,
                				"customer.orderString":"visitTime:desc",
    	     					fetchProperties:intentionregister_Props.gridFetchProperties
                		}
                		return obj;
                },
                model : {
                    columns : [{
                        name : "customer.personalInfo.name",
                        label : "姓名",
                        format: "link",
                        formatparams: {
                            key: "name",
                            handler: function(index, data, rowEL) {
                            	intentionRegisterGrid_Events.showDetail(widget,data,true);
                            }
                        }
                    },{
                        name : "customer.personalInfo.mobilePhone",
                        label : "联系电话",
                    },{
                        name : "customer.productType.product.name",
                        label : "产品",
                    },{
                        name : "customer.productType.name",
                        label : "类型",
                    },{
                        name : "customer.intention.value",
                        label : "意向",
                    },{
                        name : "customer.status.value",
                        label : "状态",
                    },{
                        name : "customer.visitTime",
                        label : "最新来访时间",
                        format:"date",
						formatparams:{
					    	mode:"YYYY-MM-DD HH:mm"
					    }
                    },{
                        name : "customer.returnVisitTime",
                        label : "最新回访时间",
                        format:"date",
						formatparams:{
					    	mode:"YYYY-MM-DD HH:mm"
					    }
                    },{
                        name : "saleConsultant.name",
                        label : "销售顾问",
                    },{
                        name : "show",
                        label : "操作",
    					format:"button",
						formatparams:[{
							id:"visit",
							text:"来访",
							handler:function(index,data,rowEle){
								intentionRegisterGrid_Events.showDetail(widget,data,false,"Visit");
							}
						},{
							id:"update",
							text:"修改",
							handler:function(index,data,rowEle){
								widget.set("edit", true);
								intentionRegisterGrid_Events.showDetail(widget,data,false);
							}
						}]
                    }]
                }
            });
        	widget.set("grid",grid);
        }
    };
    module.exports = instance;
});
